<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="author" content="史帅超">
        <title>循环</title>
        <script>
            
        </script>
    </head>
    <body>
        
        <script>
            // 计算1*2*3*4...*10
            var x =1;
            var i = 1;
            for(i=1;i<=10;i++){
                x=x*i;
            }
            if(x === 3628800){
                alert ('1x2x3x4...x10 = ' +x);
            }
            else {
                alert('计算错误');
            }

            // for循环最常用的地方是利用索引来遍历数组
            // for...in
            var obj = {
                name: "小明",
                age: 18,
                city:"郑州"
            }
            for(key in obj){
                console.log(key);//name,age,city
            }

            // 
            var array =['a','b','c']
            for(mn in array){
                console.log(mn);//'0','1','2'
                console.log(array[mn]);//'a','b','c'
                // 此时得到的是string字符串，而不是Number数字
            }

            // 

        </script>
    </body>
</html>